<%--
  Created by IntelliJ IDEA.
  User: 25003
  Date: 2025/4/13
  Time: 22:27
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%--student_edit--%>
<script type="text/javascript" src="${pageContext.request.contextPath}/assert/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/assert/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/assert/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/assert/js/main.min.js"></script>
<%--消息提示--%>
<script src="${pageContext.request.contextPath}/assert/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/assert/js/lightyear.js"></script>
<!--日期选择插件-->
<script src="${pageContext.request.contextPath}/assert/js/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="${pageContext.request.contextPath}/assert/js/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<c:if test="${sessionScope.role == 'student'}">

   <%-- $(function (){
        //修改个人信息的逻辑代码
        $("#studentPersonal").on('submit',function (event){
            //组织默认提交
            event.preventDefault();
            lightyear.loading('show');//显示加载
            // 假设ajax提交操作
            //进行表单数据的序列化
            var formData = $(this).serialize();
            console.log(formData)
            $.ajax({
                type:"post",
                url:$(this).attr("action"),
                data:formData,
                dataType:"json",
                success:function (data){
                    if(data.success){
                        lightyear.loading('hide');
                        //用户修改信息之后刷新页面不用进行页面的提交
                        &lt;%&ndash;lightyear.url('${pageContext.request.contextPath}/student');&ndash;%&gt;
                        lightyear.notify(data.msg, 'success',500);
                    }else {
                        lightyear.loading('hide');
                        lightyear.notify(data.msg, 'danger', 2000);
                    }
                },
                error:function (){
                    console.log("请求服务失败！")
                    lightyear.loading('hide');
                    lightyear.notify("请求失败请检查！", 'danger', 3000);
                }
            })})
        //修改密码js代码
        $("#studentPassword").on('submit',function (event){
            //组织默认提交
            event.preventDefault();
            lightyear.loading('show');//显示加载
            // 假设ajax提交操作
            //进行表单数据的序列化
            var formData = $(this).serialize();
            console.log(formData)
            $.ajax({
                type:"post",
                url:$(this).attr("action"),
                data:formData,
                dataType:"json",
                success:function (data){
                    if(data.success){
                        lightyear.loading('hide');
                        //用户修改信息之后刷新页面不用进行页面的提交
                        &lt;%&ndash;lightyear.url('${pageContext.request.contextPath}/student');&ndash;%&gt;
                        lightyear.notify(data.msg, 'success',500);
                    }else {
                        lightyear.loading('hide');
                        lightyear.notify(data.msg, 'danger', 2000);
                    }
                },
                error:function (){
                    console.log("请求服务失败！")
                    lightyear.loading('hide');
                    lightyear.notify("请求失败请检查！", 'danger', 3000);
                }
            })})
    })
</script>
</c:if>--%>



<script type="text/javascript">
    $(function () {
        //修改个人信息
        $('#studentPersonal').on('submit', function(event) {
            // 阻止表单的默认提交行为
            event.preventDefault();
            lightyear.loading('show');
            // 序列化表单数据
            var formData = $(this).serialize();
            // 使用AJAX发送数据
            console.log(formData)
            $.ajax({
                type: 'POST',
                url: $(this).attr("action"),
                data: formData,
                success: function(response) {
                    if(response.success){
                        lightyear.loading('hide');
                        lightyear.notify(response.msg, 'success', 500);
                    }else{
                        lightyear.loading('hide');
                        lightyear.notify(response.msg, 'danger', 1000);
                    }
                },
                error: function(xhr, status, error) {
                    lightyear.loading('hide');
                    lightyear.notify("请求失败", 'danger', 1000);
                }
            });
        });
        $('#studentPassword').on('submit', function(event) {
            // 阻止表单的默认提交行为
            event.preventDefault();
            // 序列化表单数据
            var formData = $(this).serialize();
            lightyear.loading('show');
            // 使用AJAX发送数据
            $.ajax({
                type: 'POST',
                url: $(this).attr("action"),
                data: formData,
                //这里的response指的是从后端传递过来的data
                success: function(response) {
                    if(response.success){
                        lightyear.loading('hide');
                        lightyear.notify(response.msg, 'success', 500);
                    }else{
                        lightyear.loading('hide');
                        lightyear.notify(response.msg, 'danger', 1000);
                    }
                },
                error: function(xhr, status, error) {
                    lightyear.loading('hide');
                    lightyear.notify("请求失败", 'danger', 1000);
                }
            });
        });})
</script>
</c:if>